package com.dome.mvp.presenter;

import android.app.Activity;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.Observer;

import com.dome.mvp.base.BasePresenter;
import com.dome.mvp.base.ICallBack;
import com.dome.mvp.bean.MainBean;
import com.dome.mvp.model.impl.MainModelImpl;
import com.dome.mvp.view.IMainView;

import java.util.List;

/**
 * Time: 6/1/2021 9:16
 * Author: TAO
 * Description:
 */
public class MainPresenter extends BasePresenter<IMainView> implements ICallBack<List<Fragment>> {

    private final MutableLiveData<List<Fragment>> liveData = new MutableLiveData<>();


    @Override
    public void onCreate() {
        super.onCreate();
        MainModelImpl model = new MainModelImpl();
        model.showData(this);
    }


    @Override
    public void success(List<Fragment> mainBean) {
        liveData.postValue(mainBean);
    }

    @Override
    public void showError(String error) {
        getView().showError(error);
    }


    public MutableLiveData<List<Fragment>> getLiveData() {
        return liveData;
    }

    public View.OnClickListener homeClick = v -> {
        getView().showFragment(0);
    };
    public View.OnClickListener squareClick = v -> {
        getView().showFragment(1);
    };
    public View.OnClickListener chatClick = v -> {
        getView().showFragment(2);
    };
    public View.OnClickListener mineClick = v -> {
        getView().showFragment(3);
    };


}
